package com.thinvent.remotepassword.util;

import cn.hutool.extra.spring.SpringUtil;
import com.thinvent.remotepassword.entity.User;
import com.thinvent.remotepassword.service.UserService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class UserUtil {

    private static Map<String,String> map = new HashMap<>();
    public static String getUserName(String userid){
        if(!map.containsKey(userid)){
            UserService userService = SpringUtil.getBean(UserService.class);
            List<User> list = userService.list();
            list.stream().forEach(e ->{
                map.put(e.getId().toString(),e.getUsername());
            });
        }
        return map.get(userid);
    }
}
